package com.valdemar.android.givemeanswers.server;

import java.util.List;

import com.valdemar.android.givemeanswers.annotation.ServiceMethod;


public class GiveMeAnswersService
{
	
	static DataStore db = new DataStore();
	

	@ServiceMethod
	public Question createQuestion()
	{
		return db.update(new Question());
	}

	@ServiceMethod
	public Question readQuestion(Long id)
	{
		return db.find(id);
	}

	@ServiceMethod
	public Question updateQuestion(Question question)
	{
		question.setEmailAddress(DataStore.getUserEmail());
		question = db.update(question);
		//TODO: re-enable
//         DataStore.sendC2DMUpdate(TaskChange.UPDATE + TaskChange.SEPARATOR + task.getId());
         return question;
	}

	@ServiceMethod
	public void deleteQuestion(Question question)
	{
		 db.delete(question.getId());

	}

	@ServiceMethod
	public List<Question> queryQuestions()
	{
		   return db.findAll();
	}

}
